.class Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;
.super Ljava/lang/Object;
.source "SpicyDealsViewPagerAdapter.java"

# interfaces
.implements Ljava/lang/Runnable;


# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x0
    name = "PostWorker"
.end annotation


# instance fields
.field private p:I

.field final synthetic this$0:Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;

.field private update:Z


# direct methods
.method public constructor <init>(Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;IZ)V
    .locals 1
    .parameter
    .parameter "p"
    .parameter "update"

    .prologue
    .line 405
    iput-object p1, p0, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;->this$0:Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 406
    iput p2, p0, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;->p:I

    .line 407
    iput-boolean p3, p0, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;->update:Z

    .line 408
    new-instance v0, Ljava/lang/Thread;

    invoke-direct {v0, p0}, Ljava/lang/Thread;-><init>(Ljava/lang/Runnable;)V

    .line 409
    return-void
.end method


# virtual methods
.method public run()V
    .locals 17

    .prologue
    .line 412
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;->this$0:Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;

    #getter for: Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->mAdapterArray:Ljava/util/ArrayList;
    invoke-static {v1}, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->access$1(Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;)Ljava/util/ArrayList;

    move-result-object v1

    move-object/from16 v0, p0

    iget v2, v0, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;->p:I

    invoke-virtual {v1, v2}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object v11

    check-cast v11, Lcom/opongo/android/custom/PostListAdapter;

    .line 414
    .local v11, mAdapter:Lcom/opongo/android/custom/PostListAdapter;
    iget-object v13, v11, Lcom/opongo/android/custom/PostListAdapter;->posts:Ljava/util/ArrayList;

    .line 416
    .local v13, posts:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lcom/opongo/blogapp/common/Post;>;"
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;->this$0:Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;

    iget-object v1, v1, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->dbManager:Lcom/opongo/blogapp/manager/DatabaseManager;

    .line 417
    move-object/from16 v0, p0

    iget-object v2, v0, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;->this$0:Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;

    iget-object v2, v2, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->dbManager:Lcom/opongo/blogapp/manager/DatabaseManager;

    invoke-virtual {v2}, Lcom/opongo/blogapp/manager/DatabaseManager;->getTableName()Ljava/lang/String;

    move-result-object v2

    move-object/from16 v0, p0

    iget v3, v0, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;->p:I

    .line 416
    invoke-virtual {v1, v2, v3}, Lcom/opongo/blogapp/manager/DatabaseManager;->queryForBlogTypeID(Ljava/lang/String;I)I

    move-result v7

    .line 419
    .local v7, blogTypeID:I
    if-eqz v13, :cond_2

    .line 420
    invoke-virtual {v13}, Ljava/util/ArrayList;->size()I

    move-result v1

    int-to-long v1, v1

    const-wide/16 v3, 0x0

    cmp-long v1, v1, v3

    if-lez v1, :cond_a

    .line 423
    invoke-static {}, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->access$0()Ljava/lang/String;

    move-result-object v1

    new-instance v2, Ljava/lang/StringBuilder;

    const-string v3, "SizePosts: "

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v13}, Ljava/util/ArrayList;->size()I

    move-result v3

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v3, " blogTypeID:"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    .line 424
    invoke-virtual {v2, v7}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    .line 423
    invoke-static {v1, v2}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 427
    :try_start_0
    invoke-virtual {v13}, Ljava/util/ArrayList;->iterator()Ljava/util/Iterator;

    move-result-object v16

    :cond_0
    :goto_0
    invoke-interface/range {v16 .. v16}, Ljava/util/Iterator;->hasNext()Z
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    move-result v1

    if-nez v1, :cond_3

    .line 465
    :goto_1
    sget-boolean v1, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->DEBUG:Z

    if-eqz v1, :cond_1

    .line 466
    new-instance v1, Ljava/lang/StringBuilder;

    const-string v2, "SELECT * FROM "

    invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-object v2, v0, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;->this$0:Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;

    iget-object v2, v2, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->dbManager:Lcom/opongo/blogapp/manager/DatabaseManager;

    invoke-virtual {v2}, Lcom/opongo/blogapp/manager/DatabaseManager;->getTableName()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    .line 467
    const-string v2, " WHERE 1"

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    .line 466
    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v14

    .line 468
    .local v14, q:Ljava/lang/String;
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;->this$0:Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;

    iget-object v1, v1, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->dbManager:Lcom/opongo/blogapp/manager/DatabaseManager;

    invoke-virtual {v1, v14}, Lcom/opongo/blogapp/manager/DatabaseManager;->query(Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v8

    .line 469
    .local v8, cursor:Landroid/database/Cursor;
    invoke-interface {v8}, Landroid/database/Cursor;->getCount()I

    move-result v9

    .line 470
    .local v9, dealsCount:I
    invoke-interface {v8}, Landroid/database/Cursor;->close()V

    .line 471
    const-string v14, "SELECT * FROM post_blogtype WHERE 1"

    .line 473
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;->this$0:Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;

    iget-object v1, v1, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->dbManager:Lcom/opongo/blogapp/manager/DatabaseManager;

    invoke-virtual {v1, v14}, Lcom/opongo/blogapp/manager/DatabaseManager;->query(Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v8

    .line 474
    invoke-interface {v8}, Landroid/database/Cursor;->getCount()I

    move-result v15

    .line 475
    .local v15, refCount:I
    invoke-interface {v8}, Landroid/database/Cursor;->close()V

    .line 476
    const-string v1, "TestCursor"

    .line 478
    const-string v2, "SizeDownload before - deals:%d  ref:%d blogTypeID: %d"

    const/4 v3, 0x3

    new-array v3, v3, [Ljava/lang/Object;

    const/4 v4, 0x0

    .line 479
    invoke-static {v9}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v5

    aput-object v5, v3, v4

    const/4 v4, 0x1

    invoke-static {v15}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v5

    aput-object v5, v3, v4

    const/4 v4, 0x2

    invoke-static {v7}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v5

    aput-object v5, v3, v4

    .line 477
    invoke-static {v2, v3}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v2

    .line 476
    invoke-static {v1, v2}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 482
    .end local v8           #cursor:Landroid/database/Cursor;
    .end local v9           #dealsCount:I
    .end local v14           #q:Ljava/lang/String;
    .end local v15           #refCount:I
    :cond_1
    move-object/from16 v0, p0

    iget-boolean v1, v0, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;->update:Z

    if-eqz v1, :cond_9

    .line 483
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;->this$0:Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;

    iget-object v1, v1, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->dbManager:Lcom/opongo/blogapp/manager/DatabaseManager;

    invoke-virtual {v1, v7}, Lcom/opongo/blogapp/manager/DatabaseManager;->cleanPosts(I)V

    .line 490
    :goto_2
    sget-boolean v1, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->DEBUG:Z

    if-eqz v1, :cond_2

    .line 491
    new-instance v1, Ljava/lang/StringBuilder;

    const-string v2, "SELECT * FROM "

    invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-object v2, v0, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;->this$0:Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;

    iget-object v2, v2, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->dbManager:Lcom/opongo/blogapp/manager/DatabaseManager;

    invoke-virtual {v2}, Lcom/opongo/blogapp/manager/DatabaseManager;->getTableName()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    .line 492
    const-string v2, " WHERE 1"

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    .line 491
    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v14

    .line 493
    .restart local v14       #q:Ljava/lang/String;
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;->this$0:Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;

    iget-object v1, v1, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->dbManager:Lcom/opongo/blogapp/manager/DatabaseManager;

    invoke-virtual {v1, v14}, Lcom/opongo/blogapp/manager/DatabaseManager;->query(Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v8

    .line 494
    .restart local v8       #cursor:Landroid/database/Cursor;
    invoke-interface {v8}, Landroid/database/Cursor;->getCount()I

    move-result v9

    .line 495
    .restart local v9       #dealsCount:I
    invoke-interface {v8}, Landroid/database/Cursor;->close()V

    .line 496
    const-string v14, "SELECT * FROM post_blogtype WHERE 1"

    .line 498
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;->this$0:Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;

    iget-object v1, v1, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->dbManager:Lcom/opongo/blogapp/manager/DatabaseManager;

    invoke-virtual {v1, v14}, Lcom/opongo/blogapp/manager/DatabaseManager;->query(Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v8

    .line 499
    invoke-interface {v8}, Landroid/database/Cursor;->getCount()I

    move-result v15

    .line 500
    .restart local v15       #refCount:I
    invoke-interface {v8}, Landroid/database/Cursor;->close()V

    .line 501
    const-string v1, "TestCursor"

    .line 503
    const-string v2, "SizeDownload after - deals:%d  ref:%d blogTypeID: %d"

    const/4 v3, 0x3

    new-array v3, v3, [Ljava/lang/Object;

    const/4 v4, 0x0

    .line 504
    invoke-static {v9}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v5

    aput-object v5, v3, v4

    const/4 v4, 0x1

    invoke-static {v15}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v5

    aput-object v5, v3, v4

    const/4 v4, 0x2

    invoke-static {v7}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v5

    aput-object v5, v3, v4

    .line 502
    invoke-static {v2, v3}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v2

    .line 501
    invoke-static {v1, v2}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 511
    .end local v8           #cursor:Landroid/database/Cursor;
    .end local v9           #dealsCount:I
    .end local v14           #q:Ljava/lang/String;
    .end local v15           #refCount:I
    :cond_2
    :goto_3
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;->this$0:Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;

    #getter for: Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->activity:Landroid/app/Activity;
    invoke-static {v1}, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->access$3(Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;)Landroid/app/Activity;

    move-result-object v1

    new-instance v2, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$UpdateAdapter;

    move-object/from16 v0, p0

    iget-object v3, v0, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;->this$0:Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;

    move-object/from16 v0, p0

    iget v4, v0, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;->p:I

    invoke-direct {v2, v3, v4}, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$UpdateAdapter;-><init>(Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;I)V

    invoke-virtual {v1, v2}, Landroid/app/Activity;->runOnUiThread(Ljava/lang/Runnable;)V

    .line 512
    return-void

    .line 427
    :cond_3
    :try_start_1
    invoke-interface/range {v16 .. v16}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v12

    check-cast v12, Lcom/opongo/blogapp/common/Post;

    .line 429
    .local v12, post:Lcom/opongo/blogapp/common/Post;
    :cond_4
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;->this$0:Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;

    iget-object v1, v1, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->dbManager:Lcom/opongo/blogapp/manager/DatabaseManager;

    invoke-virtual {v1}, Lcom/opongo/blogapp/manager/DatabaseManager;->isLocked()Z

    move-result v1

    if-nez v1, :cond_4

    .line 433
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;->this$0:Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;

    iget-object v1, v1, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->dbManager:Lcom/opongo/blogapp/manager/DatabaseManager;

    iget v2, v12, Lcom/opongo/blogapp/common/Post;->id:I

    int-to-long v2, v2

    invoke-virtual {v1, v2, v3}, Lcom/opongo/blogapp/manager/DatabaseManager;->itemExists(J)Z

    move-result v1

    if-eqz v1, :cond_6

    .line 434
    sget-boolean v1, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->DEBUG:Z

    if-eqz v1, :cond_5

    .line 435
    invoke-static {}, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->access$0()Ljava/lang/String;

    move-result-object v1

    .line 436
    new-instance v2, Ljava/lang/StringBuilder;

    const-string v3, "Updating item with id "

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    .line 437
    iget v3, v12, Lcom/opongo/blogapp/common/Post;->id:I

    invoke-static {v3}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    .line 436
    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    .line 435
    invoke-static {v1, v2}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 438
    :cond_5
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;->this$0:Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;

    iget-object v1, v1, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->dbManager:Lcom/opongo/blogapp/manager/DatabaseManager;

    invoke-virtual {v1, v12}, Lcom/opongo/blogapp/manager/DatabaseManager;->updatePost(Lcom/opongo/blogapp/common/Post;)I

    .line 449
    :goto_4
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;->this$0:Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;

    iget-object v1, v1, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->dbManager:Lcom/opongo/blogapp/manager/DatabaseManager;

    iget v2, v12, Lcom/opongo/blogapp/common/Post;->id:I

    int-to-long v2, v2

    invoke-virtual {v1, v2, v3, v7}, Lcom/opongo/blogapp/manager/DatabaseManager;->itemExists(JI)Z

    move-result v1

    if-nez v1, :cond_8

    .line 450
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;->this$0:Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;

    iget-object v1, v1, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->dbManager:Lcom/opongo/blogapp/manager/DatabaseManager;

    iget v2, v12, Lcom/opongo/blogapp/common/Post;->id:I

    int-to-long v2, v2

    int-to-long v4, v7

    iget v6, v12, Lcom/opongo/blogapp/common/Post;->order:I

    invoke-virtual/range {v1 .. v6}, Lcom/opongo/blogapp/manager/DatabaseManager;->insertPostToBlogtype(JJI)J

    .line 455
    :goto_5
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;->this$0:Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;

    iget v1, v1, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->post_id:I

    if-eqz v1, :cond_0

    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;->this$0:Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;

    iget v1, v1, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->post_id:I

    iget v2, v12, Lcom/opongo/blogapp/common/Post;->id:I

    if-ne v1, v2, :cond_0

    .line 456
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;->this$0:Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;

    invoke-virtual {v13, v12}, Ljava/util/ArrayList;->indexOf(Ljava/lang/Object;)I

    move-result v2

    iput v2, v1, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->positionInDetailView:I
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0

    goto/16 :goto_0

    .line 459
    .end local v12           #post:Lcom/opongo/blogapp/common/Post;
    :catch_0
    move-exception v10

    .line 461
    .local v10, e:Ljava/lang/Exception;
    invoke-static {}, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->access$0()Ljava/lang/String;

    move-result-object v1

    const-string v2, "Insert Post Exeption"

    invoke-static {v1, v2}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I

    .line 462
    invoke-static {}, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->access$0()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v10}, Ljava/lang/Exception;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-static {v1, v2}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I

    goto/16 :goto_1

    .line 441
    .end local v10           #e:Ljava/lang/Exception;
    .restart local v12       #post:Lcom/opongo/blogapp/common/Post;
    :cond_6
    :try_start_2
    sget-boolean v1, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->DEBUG:Z

    if-eqz v1, :cond_7

    .line 442
    invoke-static {}, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->access$0()Ljava/lang/String;

    move-result-object v1

    .line 443
    new-instance v2, Ljava/lang/StringBuilder;

    invoke-virtual {v13, v12}, Ljava/util/ArrayList;->indexOf(Ljava/lang/Object;)I

    move-result v3

    invoke-static {v3}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    .line 444
    const-string v3, ". Persisting item with id "

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    .line 445
    iget v3, v12, Lcom/opongo/blogapp/common/Post;->id:I

    invoke-static {v3}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    .line 443
    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    .line 442
    invoke-static {v1, v2}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 446
    :cond_7
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;->this$0:Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;

    iget-object v1, v1, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->dbManager:Lcom/opongo/blogapp/manager/DatabaseManager;

    invoke-virtual {v1, v12}, Lcom/opongo/blogapp/manager/DatabaseManager;->insertPost(Lcom/opongo/blogapp/common/Post;)J

    goto/16 :goto_4

    .line 452
    :cond_8
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;->this$0:Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;

    iget-object v1, v1, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->dbManager:Lcom/opongo/blogapp/manager/DatabaseManager;

    iget v2, v12, Lcom/opongo/blogapp/common/Post;->id:I

    int-to-long v2, v2

    int-to-long v4, v7

    iget v6, v12, Lcom/opongo/blogapp/common/Post;->order:I

    invoke-virtual/range {v1 .. v6}, Lcom/opongo/blogapp/manager/DatabaseManager;->updatePostToBlogtype(JJI)J
    :try_end_2
    .catch Ljava/lang/Exception; {:try_start_2 .. :try_end_2} :catch_0

    goto :goto_5

    .line 485
    .end local v12           #post:Lcom/opongo/blogapp/common/Post;
    :cond_9
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;->this$0:Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;

    iget-object v1, v1, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->dbManager:Lcom/opongo/blogapp/manager/DatabaseManager;

    new-instance v2, Ljava/lang/StringBuilder;

    const-string v3, "UPDATE post_blogtype SET newpost = 0 WHERE blogtype_id = "

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    .line 487
    invoke-virtual {v2, v7}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    .line 485
    invoke-virtual {v1, v2}, Lcom/opongo/blogapp/manager/DatabaseManager;->execQuery(Ljava/lang/String;)V

    goto/16 :goto_2

    .line 507
    :cond_a
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter$PostWorker;->this$0:Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;

    iget-object v1, v1, Lcom/opongo/android/custom/SpicyDealsViewPagerAdapter;->dbManager:Lcom/opongo/blogapp/manager/DatabaseManager;

    invoke-virtual {v1, v7}, Lcom/opongo/blogapp/manager/DatabaseManager;->cleanPosts(I)V

    goto/16 :goto_3
.end method
